package com.tsing.bms.controller;

import com.tsing.bms.service.INoticeService;
import com.tsing.bms.vo.req.IdReqVo;
import com.tsing.bms.vo.req.IdsReqVo;
import com.tsing.bms.vo.req.NoticeAddReqVo;
import com.tsing.bms.vo.req.NoticeUpdateReqVo;
import com.tsing.bms.vo.resp.NoticeRespVo;
import com.tsing.common.annotations.SystemLog;
import com.tsing.common.utils.ResultUtil;
import com.tsing.common.vo.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author TheTsing
 * @since 2021-03-29
 */
@Api(tags = "通知管理")
@RestController
@RequestMapping("/noTice")
public class NoticeController {

    @Autowired
    private INoticeService noTiceService;

    @PostMapping("/addNotice")
    @ApiOperation(value = "新增通知")
    @SystemLog(description = "新增通知")
    public ResultData addNotice(@Validated @RequestBody NoticeAddReqVo reqVo) {
        noTiceService.addNotice(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteNotice")
    @ApiOperation(value = "删除通知")
    @SystemLog(description = "删除通知")
    public ResultData deleteNotice(@Validated @RequestBody IdsReqVo reqVo) {
        noTiceService.deleteNotice(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getNotice")
    @ApiOperation(value = "获取单个通知信息")
    @SystemLog(description = "获取单个通知信息")
    public ResultData<NoticeRespVo> getNotice(@Validated IdReqVo reqVo) {
        return ResultUtil.success(noTiceService.getNotice(reqVo));
    }

    @PutMapping("/updateNotice")
    @ApiOperation(value = "修改通知")
    @SystemLog(description = "修改通知")
    public ResultData updateNotice(@Validated @RequestBody NoticeUpdateReqVo reqVo) {
        noTiceService.updateNotice(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/noTiceList")
    @ApiOperation(value = "通知列表")
    @SystemLog(description = "通知列表")
    public ResultData<List<NoticeRespVo>> noTiceList() {
        return ResultUtil.success(noTiceService.noTiceList());
    }

}
